package com.ykt.controller;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.ArrayUtils;

import com.jfinal.ext.route.ControllerBind;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.ykt.model.Camera;
import com.ykt.vo.page.TreeNode;

@ControllerBind(controllerKey="/camera")
public class CameraController extends BaseController<Camera> {

	public CameraController() {
		super(Camera.class);
	}
	
	public void marketShop() {
        List<Record> list = null;
        String sql = "SELECT * FROM camera c WHERE c.id NOT IN (SELECT m.camera_id FROM camera_market m) AND c.id NOT IN (SELECT s.camera_id FROM camera_shop s)";

        list = Db.find(sql);
        this.renderJson(list);
    }
	
	
	/**
	 * 下拉列表多选
	 */
	public void combotree() {

		String sql="select id,device_name as name from camera";
		
		List<Record> dataList = Db.find(sql);
		List<TreeNode> list = new ArrayList<TreeNode>();
		for(Record r : dataList ){
			TreeNode rootNode = new TreeNode();
			rootNode.setId(r.getInt("id"));
			rootNode.setText(r.getStr("name"));
			rootNode.setIconCls("icon-home");
			rootNode.setCanChk(false);
			list.add(rootNode);
		}
		this.renderJson(list);
	}
}
